#if !defined(_MEMOFILE_H__INCLUDED_)
#define _MEMOFILE_H__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "DBFDef.h"
#include "DBFException.h"

// CMemoFile - a Memo File

class TDBFUTILITY_IMPEXP CMemoFile : public CFile
{

friend class CFPTMemoFile;
friend class CDBTMemoFile;
friend class CSMTMemoFile;

	DECLARE_DYNAMIC(CMemoFile)

// Constructors
public:
	CMemoFile();

// Attributes
public:
	DBT_HEAD*	m_pDBTHead;

public:
	~CMemoFile();

	virtual BOOL Open(LPCTSTR lpszName, UINT nOpenFlag);
	virtual void Close();
	virtual BOOL IsOpen() const;
	
	virtual UINT GetMemoFileType();

	virtual BOOL ReadMemoRecord(DBF_ULONG lOffsetRec, DBF_LONG& nLen, CTDbfString& strMemo); 
	virtual BOOL ReadMemoRecord(DBF_ULONG lOffsetRec, DBF_LONG& nLen, unsigned char** pMemoData);
	virtual BOOL WriteMemoRecord(DBF_ULONG& lOffsetRec, DBF_LONG& nLen, CTDbfString& strMemo);

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif


protected:
	BOOL ReadHeader();
	BOOL WriteHeader();

private:
	DBF_LONG AddMemoRecord(CTDbfString& strMemo);
	void UpdateMemoRecord(DBF_ULONG lOffsetRec, CTDbfString& strMemo);

	BOOL		m_bOpen;
	DBF_ULONG	m_nNextBlock;
	DBF_LONG	m_nBlockSize;
};

//{{AFX_INSERT_LOCATION}}
#endif // !defined(_MEMOFILE_H__INCLUDED_)

